<?php

 if(isset($_POST['comment_content'])){
	
 		$md=new Model;
		$data=array(
			'tieude'=>$_POST['comment_tieude'],
			'url'=>$_POST['comment_url'],
			'type'=>$_POST['comment_type'],
			'type_id'=>intval($_POST['comment_id']),
			'username'=>$_POST['comment_user'],
			'noidung'=>$_POST['comment_content'],
			'ip'=>$_POST['ip'],
			'time_add'=>date('Y-m-d H:i:s')
		);
		$md->insert('comment',$data);
		echo mysql_error();
/*		if($_POST['comment_type']=='channel'){
		echo "abc";
		//Send mail to user channel, update inbox cua user do = so comment
										$user=cache_get_user($_POST['comment_tieude']);
										
										if($user && $_POST['comment_user']!=$user['username']){
												$to      = $user['email'];
												$subject = $_POST['comment_user']." gửi bạn tin nhắn tại Mộng.vn";
												$message="Nội Dung Tin Nhắn :<Br/>".$_POST['comment_content']."<br/> <a href='".HOME."member/".$user['username']."'>Xem chi tiết...</a>  ";
												$headers  = "From:Mộng.vn<noreply@mong.vn>\r\n";
												$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
												mail($to,$subject,$message,$headers); //mail thanh cong hay that bai deo quan tam
												
												//Update inbox
												$md->nonquery("update users set inbox=inbox+1 where username='".$user['username']."'");
												//Xong --thiet là vãi linh hồn
												cache_get_user($user['username'],false); // Clear cache user
										
										}
		}*/
		exit();
 
 }// End of add comment 